home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 May / PCWMAY06.iso / Software / Freeware / First Page 2006 3.00 / fp2006-final-3.00-setup.exe / {app} / Iscripts / Maths & Calculations / jerons-chmod-calc.izs < prev    next >
Text File  |  2005-07-29  |  10KB  |  275 lines

  1. <!NOWIZARD>
  2.  
  3. <!TITLE>Jeroen's Chmod Calculator
  4. <!/TITLE>
  5.  
  6. <!DESCRIPTION>Jeroen's Chmod calculator is the most robust calculator of its kind. It allows you to lookup and display the permission setting value (ie: 755) for files in 3 different ways, including its text equivalent (ie: -rwxr-xr-x). With this script you have all you could need to change your server files' permission! 
  7. <!/DESCRIPTION> 
  8.  
  9. <!CATEGORY>math related<!/CATEGORY>
  10.  
  11. <!SCRIPT>
  12. <!-- START OF SCRIPT -->
  13. <script type="text/javascript">
  14. <!--
  15.  
  16. function octalchange() 
  17. {
  18.     var val = document.chmod.t_total.value;
  19.     var ownerbin = parseInt(val.charAt(0)).toString(2);
  20.     while (ownerbin.length<3) { ownerbin="0"+ownerbin; };
  21.     var groupbin = parseInt(val.charAt(1)).toString(2);
  22.     while (groupbin.length<3) { groupbin="0"+groupbin; };
  23.     var otherbin = parseInt(val.charAt(2)).toString(2);
  24.     while (otherbin.length<3) { otherbin="0"+otherbin; };
  25.     document.chmod.owner4.checked = parseInt(ownerbin.charAt(0)); 
  26.     document.chmod.owner2.checked = parseInt(ownerbin.charAt(1));
  27.     document.chmod.owner1.checked = parseInt(ownerbin.charAt(2));
  28.     document.chmod.group4.checked = parseInt(groupbin.charAt(0)); 
  29.     document.chmod.group2.checked = parseInt(groupbin.charAt(1));
  30.     document.chmod.group1.checked = parseInt(groupbin.charAt(2));
  31.     document.chmod.other4.checked = parseInt(otherbin.charAt(0)); 
  32.     document.chmod.other2.checked = parseInt(otherbin.charAt(1));
  33.     document.chmod.other1.checked = parseInt(otherbin.charAt(2));
  34.     calc_chmod(1);
  35. };
  36.  
  37. function calc_chmod(nototals)
  38. {
  39.   var users = new Array("owner", "group", "other");
  40.   var totals = new Array("","","");
  41.   var syms = new Array("","","");
  42.  
  43.     for (var i=0; i<users.length; i++)
  44.     {
  45.       var user=users[i];
  46.         var field4 = user + "4";
  47.         var field2 = user + "2";
  48.         var field1 = user + "1";
  49.         //var total = "t_" + user;
  50.         var symbolic = "sym_" + user;
  51.         var number = 0;
  52.         var sym_string = "";
  53.     
  54.         if (document.chmod[field4].checked == true) { number += 4; }
  55.         if (document.chmod[field2].checked == true) { number += 2; }
  56.         if (document.chmod[field1].checked == true) { number += 1; }
  57.     
  58.         if (document.chmod[field4].checked == true) {
  59.             sym_string += "r";
  60.         } else {
  61.             sym_string += "-";
  62.         }
  63.         if (document.chmod[field2].checked == true) {
  64.             sym_string += "w";
  65.         } else {
  66.             sym_string += "-";
  67.         }
  68.         if (document.chmod[field1].checked == true) {
  69.             sym_string += "x";
  70.         } else {
  71.             sym_string += "-";
  72.         }
  73.     
  74.         //if (number == 0) { number = ""; }
  75.       //document.chmod[total].value = 
  76.         totals[i] = totals[i]+number;
  77.         syms[i] =  syms[i]+sym_string;
  78.     
  79.   };
  80.     if (!nototals) document.chmod.t_total.value = totals[0] + totals[1] + totals[2];
  81.     document.chmod.sym_total.value = "-" + syms[0] + syms[1] + syms[2];
  82. }
  83. window.onload=octalchange
  84. //-->
  85. </script>
  86. <form name="chmod">
  87. <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" style="font:normal 12px Verdana";>
  88. <TR ALIGN="LEFT" VALIGN="MIDDLE">
  89. <TD>Permissions: </TD>
  90. <TD><input type="text" name="t_total" value="751" size="4" onKeyUp="octalchange()"> </TD>
  91. <TD><input type="text" name="sym_total" value="" size="12" READONLY="1" STYLE='border: 0px none; font-family: "Courier New", Courier, mono;'></TD>
  92. </TR>
  93. </TABLE>
  94. <BR>
  95. <table cellpadding="2" cellspacing="0" border="0" style="font:normal 12px Verdana">
  96. <tr bgcolor="#333333">
  97. <td WIDTH="60" align="left"> </td>
  98. <td WIDTH="55" align="center" style="color:white"><b>owner
  99. </b></td>
  100. <td WIDTH="55" align="center" style="color:white"><b>group
  101. </b></td>
  102. <td WIDTH="55" align="center" style="color:white"><b>other
  103. <b></td>
  104. </tr>
  105. <tr bgcolor="#dddddd">
  106. <td WIDTH="60" align="left" nowrap BGCOLOR="#FFFFFF">read</td>
  107. <td WIDTH="55" align="center" bgcolor="#EEEEEE">
  108. <input type="checkbox" name="owner4" value="4" onclick="calc_chmod()">
  109. </td>
  110. <td WIDTH="55" align="center" bgcolor="#ffffff"><input type="checkbox" name="group4" value="4" onclick="calc_chmod()">
  111. </td>
  112. <td WIDTH="55" align="center" bgcolor="#EEEEEE">
  113. <input type="checkbox" name="other4" value="4" onclick="calc_chmod()">
  114. </td>
  115. </tr>
  116. <tr bgcolor="#dddddd">        
  117. <td WIDTH="60" align="left" nowrap BGCOLOR="#FFFFFF">write</td>
  118. <td WIDTH="55" align="center" bgcolor="#EEEEEE">
  119. <input type="checkbox" name="owner2" value="2" onclick="calc_chmod()"></td>
  120. <td WIDTH="55" align="center" bgcolor="#ffffff"><input type="checkbox" name="group2" value="2" onclick="calc_chmod()">
  121. </td>
  122. <td WIDTH="55" align="center" bgcolor="#EEEEEE">
  123. <input type="checkbox" name="other2" value="2" onclick="calc_chmod()">
  124. </td>
  125. </tr>
  126. <tr bgcolor="#dddddd">        
  127. <td WIDTH="60" align="left" nowrap BGCOLOR="#FFFFFF">execute</td>
  128. <td WIDTH="55" align="center" bgcolor="#EEEEEE">
  129. <input type="checkbox" name="owner1" value="1" onclick="calc_chmod()">
  130. </td>
  131. <td WIDTH="55" align="center" bgcolor="#ffffff"><input type="checkbox" name="group1" value="1" onclick="calc_chmod()">
  132. </td>
  133. <td WIDTH="55" align="center" bgcolor="#EEEEEE">
  134. <input type="checkbox" name="other1" value="1" onclick="calc_chmod()">
  135. </td>
  136. </tr>
  137. </table>
  138. </form>
  139. <!-- END OF SCRIPT -->
  140. <!/SCRIPT>
  141.  
  142. <!PREVIEW>
  143. <!-- START OF SCRIPT -->
  144. <script type="text/javascript">
  145. <!--
  146.  
  147. function octalchange() 
  148. {
  149.     var val = document.chmod.t_total.value;
  150.     var ownerbin = parseInt(val.charAt(0)).toString(2);
  151.     while (ownerbin.length<3) { ownerbin="0"+ownerbin; };
  152.     var groupbin = parseInt(val.charAt(1)).toString(2);
  153.     while (groupbin.length<3) { groupbin="0"+groupbin; };
  154.     var otherbin = parseInt(val.charAt(2)).toString(2);
  155.     while (otherbin.length<3) { otherbin="0"+otherbin; };
  156.     document.chmod.owner4.checked = parseInt(ownerbin.charAt(0)); 
  157.     document.chmod.owner2.checked = parseInt(ownerbin.charAt(1));
  158.     document.chmod.owner1.checked = parseInt(ownerbin.charAt(2));
  159.     document.chmod.group4.checked = parseInt(groupbin.charAt(0)); 
  160.     document.chmod.group2.checked = parseInt(groupbin.charAt(1));
  161.     document.chmod.group1.checked = parseInt(groupbin.charAt(2));
  162.     document.chmod.other4.checked = parseInt(otherbin.charAt(0)); 
  163.     document.chmod.other2.checked = parseInt(otherbin.charAt(1));
  164.     document.chmod.other1.checked = parseInt(otherbin.charAt(2));
  165.     calc_chmod(1);
  166. };
  167.  
  168. function calc_chmod(nototals)
  169. {
  170.   var users = new Array("owner", "group", "other");
  171.   var totals = new Array("","","");
  172.   var syms = new Array("","","");
  173.  
  174.     for (var i=0; i<users.length; i++)
  175.     {
  176.       var user=users[i];
  177.         var field4 = user + "4";
  178.         var field2 = user + "2";
  179.         var field1 = user + "1";
  180.         //var total = "t_" + user;
  181.         var symbolic = "sym_" + user;
  182.         var number = 0;
  183.         var sym_string = "";
  184.     
  185.         if (document.chmod[field4].checked == true) { number += 4; }
  186.         if (document.chmod[field2].checked == true) { number += 2; }
  187.         if (document.chmod[field1].checked == true) { number += 1; }
  188.     
  189.         if (document.chmod[field4].checked == true) {
  190.             sym_string += "r";
  191.         } else {
  192.             sym_string += "-";
  193.         }
  194.         if (document.chmod[field2].checked == true) {
  195.             sym_string += "w";
  196.         } else {
  197.             sym_string += "-";
  198.         }
  199.         if (document.chmod[field1].checked == true) {
  200.             sym_string += "x";
  201.         } else {
  202.             sym_string += "-";
  203.         }
  204.     
  205.         //if (number == 0) { number = ""; }
  206.       //document.chmod[total].value = 
  207.         totals[i] = totals[i]+number;
  208.         syms[i] =  syms[i]+sym_string;
  209.     
  210.   };
  211.     if (!nototals) document.chmod.t_total.value = totals[0] + totals[1] + totals[2];
  212.     document.chmod.sym_total.value = "-" + syms[0] + syms[1] + syms[2];
  213. }
  214. window.onload=octalchange
  215. //-->
  216. </script>
  217. <form name="chmod">
  218. <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" style="font:normal 12px Verdana";>
  219. <TR ALIGN="LEFT" VALIGN="MIDDLE">
  220. <TD>Permissions: </TD>
  221. <TD><input type="text" name="t_total" value="751" size="4" onKeyUp="octalchange()"> </TD>
  222. <TD><input type="text" name="sym_total" value="" size="12" READONLY="1" STYLE='border: 0px none; font-family: "Courier New", Courier, mono;'></TD>
  223. </TR>
  224. </TABLE>
  225. <BR>
  226. <table cellpadding="2" cellspacing="0" border="0" style="font:normal 12px Verdana">
  227. <tr bgcolor="#333333">
  228. <td WIDTH="60" align="left"> </td>
  229. <td WIDTH="55" align="center" style="color:white"><b>owner
  230. </b></td>
  231. <td WIDTH="55" align="center" style="color:white"><b>group
  232. </b></td>
  233. <td WIDTH="55" align="center" style="color:white"><b>other
  234. <b></td>
  235. </tr>
  236. <tr bgcolor="#dddddd">
  237. <td WIDTH="60" align="left" nowrap BGCOLOR="#FFFFFF">read</td>
  238. <td WIDTH="55" align="center" bgcolor="#EEEEEE">
  239. <input type="checkbox" name="owner4" value="4" onclick="calc_chmod()">
  240. </td>
  241. <td WIDTH="55" align="center" bgcolor="#ffffff"><input type="checkbox" name="group4" value="4" onclick="calc_chmod()">
  242. </td>
  243. <td WIDTH="55" align="center" bgcolor="#EEEEEE">
  244. <input type="checkbox" name="other4" value="4" onclick="calc_chmod()">
  245. </td>
  246. </tr>
  247. <tr bgcolor="#dddddd">        
  248. <td WIDTH="60" align="left" nowrap BGCOLOR="#FFFFFF">write</td>
  249. <td WIDTH="55" align="center" bgcolor="#EEEEEE">
  250. <input type="checkbox" name="owner2" value="2" onclick="calc_chmod()"></td>
  251. <td WIDTH="55" align="center" bgcolor="#ffffff"><input type="checkbox" name="group2" value="2" onclick="calc_chmod()">
  252. </td>
  253. <td WIDTH="55" align="center" bgcolor="#EEEEEE">
  254. <input type="checkbox" name="other2" value="2" onclick="calc_chmod()">
  255. </td>
  256. </tr>
  257. <tr bgcolor="#dddddd">        
  258. <td WIDTH="60" align="left" nowrap BGCOLOR="#FFFFFF">execute</td>
  259. <td WIDTH="55" align="center" bgcolor="#EEEEEE">
  260. <input type="checkbox" name="owner1" value="1" onclick="calc_chmod()">
  261. </td>
  262. <td WIDTH="55" align="center" bgcolor="#ffffff"><input type="checkbox" name="group1" value="1" onclick="calc_chmod()">
  263. </td>
  264. <td WIDTH="55" align="center" bgcolor="#EEEEEE">
  265. <input type="checkbox" name="other1" value="1" onclick="calc_chmod()">
  266. </td>
  267. </tr>
  268. </table>
  269. </form>
  270.  
  271.  
  272. <!-- END OF SCRIPT -->
  273. <!/PREVIEW>
  274.  
  275. <!RELATED>NONE<!/RELATED>